home *** CD-ROM | disk | FTP | other *** search
-
- {We at Artisoft are excited about the opportunity to communicate directly
- {to our LANtastic users. We'll be providing you with solutions for some
- {common problems, sharing some helpful hints, and encouraging you to try
- {more of LANtastics many features. This column will cover some of the
- {batch file programming techniques useful in setting up larger, more
- {complicated networks.
-
- [{Network Management}]
-
- Many LANtastic networks start simply, designed to allow users to share an
- expensive peripheral device or information in a common data base. As
- users become more familiar with the operation and advantages of a
- network, more nodes are added, both as servers and workstations, and
- managing the network becomes more complicated.
-
- As the network grows, the simple batch files described in the previous
- column become more cumbersome. Each user on the network does not
- have the same needs, and certainly does not need access to the same
- programs. Setting up an individual batch file on each machine limits each
- user to his assigned computer. If Bill works in accounting, and Jane
- works in production, neither one can work at the other's machine without
- reconfiguring the network connections on each machine.
-
- This column will use the LANtastic [NET STRING] command to present a
- scheme that allows each computer's network connections to be configured
- by user, and not by computer. The LANtasic Network Operating System
- Reference Manual describes the NET STRING command as follows:
-
- This command assigns a STRING of characters to a pre-
- existing environmental variable that is either typed in
- by the user or extracted from one of LANtastic's special
- Strings. You can use these Strings just like DOS environmental
- Strings. These are useful for prompting users to enter their
- passwords, user names or any other information. It is
- especially useful in batch files . . .
-
- This short paragraph states the purpose of the command but not the
- implications. The NET String command allows the system administrator
- to create batch files that are truly interactive! The command allows the
- administrator to store vital network information in environmental variables
- that can be used by other batch files. The NET STRING command will
- work with or without the network running.
-
- The syntax is: NET STRING (/LEFT=n)(/RIGHT=n) variable String1 String2
-
- /LEFT First character from the left that will be
- extracted from a String.
- /RIGHT The last character that will be extracted from
- a String.
- Variable Pre-existing environmental variable to receive
- a String.
- STRING1 STRING to replace environmental variable.
- STRING2 Optional sting to be concatenated with String 1.
-
-
- The environmental variable is defined within a batch file with the set
- command. Enough characters must be allocated for the largest entry you
- wish to permit.
-
- The syntax to define a variable is: SET name=xxxxxxxx
-
- Name is the name of the variable. The x's allocate the space, in this
- example the variable name is allowed to be 8 characters long.
-
- When the pre-existing environmental variable is defined in the autoexec.bat
- file, then any changes made to the String will remain in effect until the
- system is rebooted or the variable is changed with the NET STRING
- command. If the variable is defined in another batch file, the variable is
- local to that batch file. The String and its contents are lost when the batch
- file ends.
-
- The LANtastic special Strings are listed in the beginning of the NET Line
- Commands section of the manual. The special Strings used in this column
- are:
-
- ?"prompt" Prompts the user for input, and echoes input to
- screen.
- ^"prompt" Prompts the user for input, and DOES NOT echo input
- to screen.
- !"ETEXT=n" Expands the error number n to text.
- !"INSTALLED" Expands to characters corresponding to installed
- programs. N=NETBIOS, R=REDIR,S=SERVER, L=LANPUP,
- -=Not installed.
- !"LOGIN=server" Returns TRUE if already logged into server FALSE
- if not
- !"NODEID" Expands to 12 digit NETBios Node number.
- !"MACHINEID" Expands to name of machine being used.
-
- Lets set up a simple network. We will use the network described in the
- previous column. We have five computers-three ATs and two XTs. Each
- AT has one 40MB hard drive and one printer. Both XTs have 2 floppy
- drives but no hard drives or printers. Each AT has LANtastic installed as
- a server. We will name the ATs AT1, AT2, and AT3, and call the XTs XT1
- and XT2. AT1 will be the master computer on the network. This means
- that AT1 will always be booted as a server, and will contain the batch files
- that administer the network in a directory named NET.MGR.
-
- The autoexec.bat file for AT2 and AT3 is listed below the standard DOS
- prompt etc. left out for clarity:
- PATH=c:\lantasti;c:\dos;c:\bat;c\util
- REM Path including LANtastic directory
- SET answer=xxxxxxxxxxxxxxxxxxxx
- SET name=xxxxxxx
- SET password=xxxxxxxx
- REM Define environmental variables for use
- NET STRING answer ?"Install Lantastic Network (y/N)"
- REM Print STRING in quotes, wait for response, and place response in
- REM variable answer
- IF NOT %answer%==Y GOTO exit
- REM if response anything but Y exit to dos without installing network, NET
- REM STRING converts character to upper case
- LANBIOS2/AUTO
- REM Install netbios
- REDIR ATn LOGINS=3 BUFFERS=2
- REM Install redirector
- NET STRING answer ?"Install as a LANtastic Server (y/N)"
- REM Print String in quotes, wait for response, and place response in
- REM variable answer
- IF NOT %answer%==Y GOTO login
- REM if response anything but Y, continue without installing server
- SERVER
- REM Load server
- :login
- login
- REM Run login.bat
- :exit
-
- The autoexec.bat for AT1 is:
-
- PATH=c:\lantasti;c:\dos;c:\bat;c\util
- SET answer=xxxxxxxxxxxxxxxx
- SET name=xxxxxxx
- SET password=xxxxxxxx
- LANBIOS2/AUTO
- REDIR AT1 LOGINS=3 BUFFERS=2
- SERVER
- login
-
- The following batch files login.bat and logout.bat are the same on all
- computers on the network.
-
- LOGIN.BAT
-
- @ECHO OFF
- SET NET_ERROR=XXX
- :start
- NET STRING name ?"Please enter your user name"
- REM prompt for user name store in variable name
- NET STRING password ^"Please enter your password"
- REM prompt for password store in variable password
- NET STRING/LEFT=3/RIGHT=3 answer !"INSTALLED"
- REM get the third character of string returned by !"INSTALLED" special
- REM string
- REM check to see if server is loaded, you cannot have spaces before /left
- REM of /right
- IF NOT %answer%==S GOTO redir
- REM if server is not installed go to redir and log onto master server
- NET STRING answer !"Machineid"
- REM determines the local name of the computer
- NET/NOERROR LOGIN \\%answer% %name% %password%
- REM server logs into itself
- IF %NET_ERROR%==86 GOTO start
- REM If login attempt unsuccessful due to invalid user name or password
- REM try again
- NET USE lpt1 \\ATn\@printer
- REM and attaches to it's own printer
- :REDIR
- NET STRING answer !"LOGIN=AT1"
- REM Check to see if already logged into server AT1
- IF %answer%==TRUE GOTO login
- REM if already logged into server AT1 do not attempt it again
- NET LOGIN/WAIT \\AT1 %name% %password%
- REM login into master server
- NET USE z: \\AT1\MANAGER
- REM attach to shared resource Manager that is the \\AT!\c:\net.mgr
- :login
- SET tempname=xxxxxxxx
- NET STRING tempname %name% i
- CALL z:\%tempname%
- REM run the unique login file for the user, username+I.bat ie johnI.bat
- SET password=x
- REM set the password to x so no one can discover your password
-
- Logout.BAT
- SET tempname=xxxxxxxx
- NET STRING %tempname% %name% o
- CALL z:\%tempname%
- REM run the unique batch file to log user off system, username+O.bat ie.
- REM johnO.bat
- CALL reset
- REM restore current PATH
-
- The final pieces of this system are the individual batch files for each user.
- These batch files are named with username with the letter i added to the
- end of the login files and the letter o added to the logout files. These
- files contain the necessary commands to log users onto the server they
- needs to use and attach to the shared resources on that server. Thus
- each user will have two batch files in the net.mgr directory of server AT1.
- Each computer may have batch file for network configuration commands
- peculiar to the individual computer.
-
- Below are sample login and logout batch files:
-
- Johni.bat - login batch file for user John
-
- NET LOGIN/WAIT \\AT2 %name% %password%
- REM attempt to login to server AT2 if server AT2 is not available wait until
- REM it comes up or user presses escape key
- NET LOGIN/WAIT \\AT3 %name% %password%
- NET STRING/LEFT/RIGHT answer !"server=at2"
- IF %answer%==- GOTO noat2
- REM if login to at2 not successful skip attempt to use resources
- NET USE d: \\AT2\c-drive
- NET USE LPT2 \\AT2\@printer
- :noat2
- NET STRING/LEFT/RIGHT answer !"server=at3"
- IF %answer%==- GOTO noat3
- REM if login to at3 not successful skip attempt to use resources
- NET USE e: \\AT3\c-drive
- :noat3
- NET USE f: \\AT1\wp
- NET USE g: \\AT1\123data
- PATH>RESET.BAT
- REM save copy of current path to file on local drive reset.bat
- PATH=%PATH%;f:\;g:\
- REM add new directories to path
- NET STRING answer !"machineid"
- REM get name of node
- SET tempname=xxxxxxxxxxxx
- NET STRING tempname %answer% .bat
- IF EXIST z:\%tempname% call %answer%
- REM if a node specific batch file exists run it
-
- Johno.bat - logout file for user John
-
- NET/NOERROR LOGOUT \\at1
- REM suppress error messges with the /NOERROR switch just in case
- REM already logged out
- NET/NOERROR LOGOUT \\at2
- NET/NOERROR LOGOUT \\at3
-
- The following is an example of a machine specific login file for AT2 that
- has a modem on com2.
-
- AT2.BAT
-
- NET STRING/LEFT=3/RIGHT=3 answer !"Installed"
- REM is server running
- IF %ANSWER%==S NET QUEUE HALT \\at2 com2
- REM If computer is a server halt the spooling to com port #2
-
- While these files may appear to be complicated, once they are set up, the
- job of the system administrator becomes very easy. When a new node is
- added to the network, you only need to copy autoexec.bat, login.bat and
- logout.bat to the new computer. The autoexec.bat will only need to be
- edited to set the network name for the computer and to change the
- settings on the netbios, if they are not the default settings. All other files
- are stored in the net.mgr directory on the master server. Access
- permissions can be set for the net.mgr, so that no one else can edit the
- files.
-
- The NET STRING command can be used in many other places. Almost
- any batch file can benefit from the NET STRING command. With a little
- ingenuity, an entire menu-driven system can be developed, using only
- standard batch commands and NET STRING. Even if you do not use the
- batch files presented in this column, their example should explain the
- operation of this very powerful, but seldom used, command.
-
-
- I've tried to make this column as beneficial as possible. Please feel free
- to contact us if you have any questions or if there is a subject you would
- like us to cover.
-
- If you're experiencing a problem, our Technical Support department and
- electronic bulletin board service (ARTIFACTS BBS) are available at no
- charge. You may call or write to ARTISOFT at:
-
- Artisoft Inc.
- Public Relations/Lan Times
- 575 E. River Rd.
- Tucson, Az. 85704
- Tele: (602) 293-6363
- FAX: (602) 293-8065
- BBS: (602) 293-0065
-
- Note: These batch files were developed using LANtastic NOS V3.0x.
- Version 3.00 introduced several new features including the NET
- LOGIN/WAIT command used in these batch files. The software upgrade
- is available from Artisoft for $50.00.
-
- {THIS ARTICLE REPRODUCED HERE WITH THE PERMISSION OF "LAN
- MAGAZINE"}
-
-
-